package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Setter
@Getter
@JsonIgnoreProperties("handler")
public class StrategyCatalog extends BaseDomain {

    private String name;
      //所属攻略
    private Strategy strategy;
     //序号
    private Integer sequence;

    private Boolean state;

    //文章的关联
    private List<StrategyDetail> details =new ArrayList<>();

    public String getJson(){
        Map<String,Object> map=new HashMap<>();
        map.put("id", id);
        map.put("name", name);
        map.put("sequence", sequence);
        map.put("state",state);
        //当我们封装的是对象的时候,我么你需要判断一下是否存在
        if(strategy!=null){
            map.put("strategyId",strategy.getId());
            map.put("strategyName",strategy.getTitle());

        }
        return JSONUtil.toJSONString(map);
    }

}